home *** CD-ROM | disk | FTP | other *** search
- #include <exec/exec.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <clib/exec_protos.h>
- struct ConfBase
- {
- char Handle[31];
- ULONG NewSinceDate, ConfRead,ConfYM1;
- ULONG Bytes_Download,Bytes_Upload;
- ULONG Daily_Bytes_Limit,Daily_Bytes_Dld;
- USHORT Upload,Downloads,RatioType,Ratio,Messages_Posted;
- UWORD Access;
- };
- struct User {
- char Name[31],Pass[9],Location[30],PhoneNumber[13];
- USHORT Slot_Number;
- USHORT Sec_Status,
- Sec_Board, /* File or Byte Ratio */
- Sec_Library, /* Ratio */
- Sec_Bulletin, /* Computer Type */
- Messages_Posted;
- /* Note ConfYM = the last msg you actually read, ConfRead is the same ?? */
- ULONG NewSinceDate, ConfRead[9];
- char Conference_Access[10];
- USHORT Uploads, Downloads, ConfRJoin, Times_Called;
- long Time_Last_On, Time_Used, Time_Limit, Time_Total;
- ULONG Bytes_Download, Bytes_Upload, Daily_Bytes_Limit, Daily_Bytes_Dld;
- char Expert;
- ULONG ConfYM[9];
- long BeginLogCall;
- UBYTE Protocol, UUCPA, LineLength, New_User;
- };
-
- struct NewUser
- {
- char Name[31];
- char Handle[31];
- char Pass[9];
- char Group[31];
- char PhoneNumber[13];
- char Comment[4][41];
- USHORT Slot_Number;
- USHORT AccessLvl;
- USHORT Area;
- LONG Time_Last_On,Time_Used,Time_Limit,Time_Total;
- char Expert;
- UBYTE Protocol,UUCPA,LineLength, New_User;
- USHORT ModuleAccess;
- USHORT ScreenType;
- USHORT ComputerType;
- int Active;
- int CpsUp;
- int CpsDown;
- LONG Baud;
- };
- char BBSLocal[200];
- char UserData[200];
- void InitNewDB(struct NewUser *nu);
- void ConvertDB(struct NewUser *nu,struct User *u);
- void sr(char *s);
- main(int argc,char *argv[])
- {
- char temp[100];
- char NameDB[100];
- int totalrecords;
- USHORT UserNum=0;
- FILE *fi,*fo;
- struct NewUser nu;
- struct User u;
- if(argc!=4)
- {
- printf("UsersDB version 1.0 written by Joseph Hodge\n");
- printf("Usage: UsersDB <BBS location> <UserData location> <Records>\n");
- printf(" ie: UsersDB BBS: BBS:User.Data 400 \n");
- printf("\n");
- exit(0);
- }
- strcpy(BBSLocal,argv[1]);
- strcpy(UserData,argv[2]);
- sr(BBSLocal);
- sr(UserData);
- strcpy(temp,argv[3]);
- totalrecords=atoi(temp);
- if(BBSLocal[strlen(BBSLocal)-1]!=':' && BBSLocal[strlen(BBSLocal)-1]!='/') strcat(BBSLocal,"/");
- strcpy(NameDB,BBSLocal);
- strcat(NameDB,"USER.DB");
- fi=fopen(UserData,"rb");
- if(fi==NULL)
- {
- printf("Error, Can't locate user.data\n");
- exit(0);
- }
- fo=fopen(NameDB,"wb");
- while(fread((APTR)&u,sizeof(struct User),1,fi)!=NULL)
- {
-
- if(u.Slot_Number!=0)
- {
- nu.Slot_Number=UserNum;
- ConvertDB(&nu,&u);
- strcpy(nu.Name,nu.Handle);
- fwrite((APTR)&nu,sizeof(struct NewUser),1,fo);
- UserNum +=1;
- }
-
- }
- fclose(fi);
- sprintf(NameDB,"%sUSER.KEY",BBSLocal);
- fi=fopen(NameDB,"w");
- fprintf(fi,"%d\n",UserNum);
- fclose(fi);
- InitNewDB(&nu);
- while(UserNum<totalrecords)
- {
- nu.Slot_Number=UserNum;
- fwrite((APTR)&nu,sizeof(struct NewUser),1,fo);
- UserNum +=1;
- }
- fclose(fo);
- exit(0);
- }
-
- void InitNewDB(struct NewUser *nu)
- {
- strcpy(nu->Handle,"");
- strcpy(nu->Pass,"");
- strcpy(nu->Group,"");
- strcpy(nu->PhoneNumber,"");
- strcpy(nu->Comment[0],"");
- strcpy(nu->Comment[1],"");
- strcpy(nu->Comment[2],"");
- nu->AccessLvl=0;
- nu->Area=1;
- nu->Time_Last_On=0;
- nu->Time_Used=0;
- nu->Time_Limit=0;
- nu->Time_Total=0;
- nu->Expert=0;
- nu->ModuleAccess=0;
- nu->ScreenType=0;
- nu->ComputerType=0;
- nu->Active=0;
- }
-
- void ConvertDB(struct NewUser *nu,struct User *u)
- {
- strcpy(nu->Handle,u->Name);
- strcpy(nu->Pass,u->Pass);
- strcpy(nu->Group,u->Location);
- strcpy(nu->PhoneNumber,u->PhoneNumber);
- strcpy(nu->Comment[0],"");
- strcpy(nu->Comment[1],"");
- strcpy(nu->Comment[2],"");
- nu->AccessLvl=u->Sec_Status;
- nu->Area=1;
- nu->Time_Last_On=u->Time_Last_On;
- nu->Time_Used=u->Time_Used;
- nu->Time_Limit=u->Time_Limit;
- nu->Time_Total=u->Time_Total;
- nu->Expert=u->Expert;
- nu->ModuleAccess=u->Sec_Status;
- nu->ScreenType=0;
- nu->ComputerType=u->Sec_Bulletin;
- nu->Active=1;
- }
-
- void sr(char *s)
- {
- register int i;
- i=strlen(s)-1;
- while(i>-1)
- {
- if(*(s+i)<=32) *(s+i)='\0'; else break;
- i--;
- }
- }
-